package com.lagou.edu.service.impl;

import com.lagou.edu.antation.Autowired;
import com.lagou.edu.antation.Service;
import com.lagou.edu.antation.Transactional;
import com.lagou.edu.dao.AccountDao;
import com.lagou.edu.pojo.Account;
import com.lagou.edu.service.TransferService;

@Transactional
@Service
public class TransferServiceImpl2 implements TransferService {



    // 最佳状态
    @Autowired(value = "jdbcAccountDaoImpl2")
    private AccountDao accountDao;




    @Override
    public void transfer(String fromCardNo, String toCardNo, int money) throws Exception {



        Account from = accountDao.queryAccountByCardNo(fromCardNo);
        Account to = accountDao.queryAccountByCardNo(toCardNo);

        from.setMoney(from.getMoney()-money);
        to.setMoney(to.getMoney()+money);

        accountDao.updateAccountByCardNo(to);
        int c = 1/0;
        accountDao.updateAccountByCardNo(from);






    }
}